package cn.frh.feign.hystrix;

import cn.frh.domain.User;
import cn.frh.feign.UserService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserService() {
            @Override
            public User getUserById(Long id) {
                return new User(-1L,"触发降级","发生错误 正在殴打程序员");
            }
        };
    }
}
